import {Theme} from "../../models/theme";
import {Banner} from "../../models/banner";
import {Category} from "../../models/categroy";
import {Activity} from "../../models/activity";
import {SpuPaging} from "../../models/spu-paging";
import {CouponCenterType} from "../../core/enum"
import {User} from "../../models/user"

Page({

    /**
     * 页面的初始数据
     */
    data: {
        grid: [],
        userInfo: {},
        loadingType: 'loading'
    },

    async onLoad(options) {
        this.initAllData()
        // this.initBottomSpuList()
    },

    async initBottomSpuList() {
        const paging = SpuPaging.getLatestPaging()
        this.data.spuPaging = paging
        const data = await paging.getMoreData()
        if (!data) {
            return
        }
    },

    async initAllData() {
        const grid = await Category.getHomeLocationC()
        const user_info = await User.getUserInfo()
        console.log(user_info)


        this.setData({
            grid,
            user_info
        })
    },

    onReachBottom: async function () {
        // const data = await this.data.spuPaging.getMoreData()
        // if (!data) {
        //     return
        // }
        // wx.lin.renderWaterFlow(data.items)
        // if (!data.moreData) {
        //     this.setData({
        //         loadingType: 'end'
        //     })
        // }
    },

    onGotoCoupons(event) {
        const name = event.currentTarget.dataset.aname
        wx.navigateTo({
            url: `/pages/coupon/coupon?name=${name}&type=${CouponCenterType.ACTIVITY}`
        })
    },

    onGotoWriterRegister(event){
        wx.navigateTo({
            url: `/pages/register/register`
        })
    },

    onGotoSearch(event) {
        wx.navigateTo({
            url: `/pages/search/search`
        })
    },

    onPullDownRefresh: function () {

    },


    onShareAppMessage: function () {

    }
})


